// 引入koa-router
const Router = require('koa2-router');
const router = new Router();
const sql = require('../../config/config');
//搜索
router.get('/search',async (ctx)=>{
    //获取前端传的值
    let data=ctx.query.search;
    // console.log(data);
    //数据库模糊查询
    // console.log(search);
    //发送回前端
    ctx.body=await sql(`select * from product where title like "%\\${data}%"`);
})

//暴露
module.exports =router;